<template>
  <div class="app-container">
    <el-row :gutter="20">

      <el-col :span="24" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="手机号" prop="phone_num">
            <el-input
              v-model="queryParams.phone_num"
              placeholder="请输入手机号"
              clearable
              style="width: 150px"
            />
          </el-form-item>
          <el-form-item label="银行卡" prop="card_name">
            <el-input
              v-model="queryParams.card_num"
              placeholder="请输入卡号"
              clearable
              style="width: 150px"
            />
          </el-form-item>
          <el-form-item label="姓名" prop="account_name">
            <el-input
              v-model="queryParams.account_name"
              placeholder="请输入姓名"
              clearable
              style="width: 170px"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>


        <el-table v-loading="loading" :data="userList">
          <el-table-column label="手机号" align="center" key="phone_num" prop="phone_num" v-if="columns[0].visible" />
          <el-table-column label="银行卡" align="center" key="card_num" prop="card_num" v-if="columns[1].visible"  />
          <el-table-column label="姓名" align="center" key="account_name" prop="account_name" v-if="columns[2].visible"  />
          <el-table-column label="手机/银行归属地" align="center" key="phone_city" prop="phone_city" v-if="columns[3].visible" width="160" />
          <el-table-column label="人员类型" align="center" key="type" prop="type" v-if="columns[4].visible"  />
          <el-table-column label="诈骗类型" align="center" key="fraud_type" prop="fraud_type" v-if="columns[5].visible"  />
          <el-table-column label="诈骗盘口" align="center" key="fraud_name" prop="fraud_name" v-if="columns[6].visible">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="checkDetailHandle(scope.row)"
              >{{scope.row.fraud_name}}</el-button>
            </template>

          </el-table-column>

          <el-table-column label="盘口id" align="center" key="fraud_name_id" prop="fraud_name_id" v-if="false"  />
          <el-table-column label="新增时间" align="center" prop="add_time" v-if="columns[7].visible" width="160">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.add_time) }}</span>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
          v-show="total>0"
          :total="total"
          :page-size="queryParams.pageSize"
          :current-page.sync="queryParams.pageNum"
          @current-change="getList"
          @pagination="getList"
        />
      </el-col>
    </el-row>

  </div>
</template>

<script>
import api from "@/api/case/index.api";

export default {
  name: "caseinf",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        phone_num: undefined,
        card_num: undefined,
        account_name: undefined
      },
      // 列信息
      columns: [
        { key: 0, label: `手机号`, visible: true },
        { key: 1, label: `银行卡号`, visible: true },
        { key: 2, label: `姓名`, visible: true },
        { key: 3, label: `手机归属地`, visible: true },
        { key: 4, label: `人员类型`, visible: true },
        { key: 5, label: `诈骗类型`, visible: true },
        { key: 6, label: `诈骗盘口`, visible: true },
        { key: 7, label: `新增时间`, visible: true }
      ],
      // 表单校验
      rules: {
        caseNo: [
          { required: true, message: "案件编号不能为空", trigger: "blur" }
        ],
        caseName: [
          { required: true, message: "案件名称不能为空", trigger: "blur" }
        ],
        url: [
          { required: true, message: "协查域名不能为空", trigger: "blur" }
      ]
      }
    };
  },
  watch: {
  },
  created() {
    this.getList();
  },
  methods: {
    parseTime(t){
      return t;
    },
    checkDetailHandle (row) {
      this.$router.push({
        path: '/caseDetail',
        query: {
          id: row.fraud_name_id,
          name: row.fraud_name,
        }
      })

    },
    getList() {
      this.loading = true;
      api.caseInfList(this.queryParams).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
  }
};
</script>
